import type { ISchema } from '@formily/vue'
import { TeacherSchema } from '@/views/schema/user'
import modifySchema from '@/utils/modifySchema'

export const teacherSchema: ISchema = {
  type: 'object',
  properties: {
    layout: {
      'type': 'void',
      'x-component': 'FormLayout',
      'x-component-props': {
        labelWidth: 100,
      },
      'properties': {
        gird: {
          'type': 'void',
          'x-component': 'FormGrid',
          'x-component-props': {
            minColumns: 2,
            maxColumns: 2,
          },
          'properties': {
            userId: {
              type: 'string',
            },
            ...modifySchema(TeacherSchema(), {
              userName: {
                'required': true,
                'x-reactions': {
                  dependencies: ['.userId'],
                  when: '{{Boolean($deps[0])}}',
                  fulfill: {
                    schema: {
                      'x-component-props': {
                        disabled: true,
                      },
                    },
                  },
                  otherwise: {
                    schema: {
                      'x-component-props': {
                        disabled: false,
                      },
                    },
                  },
                },
              },
              password: {
                'required': true,
                'x-reactions': {
                  dependencies: ['.userId'],
                  when: '{{Boolean($deps[0])}}',
                  fulfill: {
                    schema: {
                      'x-component-props': {
                        disabled: true,
                      },
                    },
                  },
                  otherwise: {
                    schema: {
                      'x-component-props': {
                        disabled: false,
                      },
                    },
                  },
                },
              },
              nickName: {
                required: true,
              },
              sex: {
                required: true,

              },
              status: {
                required: true,

              },
              phonenumber: {
                required: true,
              },
              remark: {
                'x-decorator-props': {
                  gridSpan: 'span 2',
                },
              },
            }),
          },
        },
      },
    },
  },
}
